<?php

namespace App\Listeners\Vote;

use App\App\Services\VoteCacheService;
use App\Events\VoteCandidateDeleted;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class CandidateDeletedListener
{
    protected $cache;

    public function __construct(VoteCacheService $cache)
    {
        $this->cache = $cache;
    }

    /**
     * Handle the event.
     *
     * @param  VoteCandidateDeleted  $event
     * @return void
     */
    public function handle(VoteCandidateDeleted $event)
    {
        $this->cache->deleteCandidateCache($event->candidate->id);
    }
}
